/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: zhongyisheng
 * Date: 2025-05-09
 * Time: 15:34
 */
public class Test {
    /**
     *
     * @param pos1 起始位置
     * @param pos2 中转位置
     * @param pos3 目标位置
     * @param n
     */
    public static void hanio (int n ,char pos1,char pos2,char pos3){
        if(n == 1){
            move(pos1, pos3);
            return;
        }
        hanio(n-1,pos1,pos3,pos2);
        move(pos1,pos3);
        hanio(n-1,pos2,pos1,pos3);
    }

    /**
     *
     * @param pos1 起始位置
     * @param pos2 目标位置
     */
    public static void move(char pos1,char pos2){
        System.out.println(pos1+" -> " + pos2);
    }
    public static void main(String[] args) {
        hanio(1,'A','B','C');
        hanio(3,'A','B','C');
        hanio(4,'A','B','C');

    }
}
